#ifndef _OH_WEAPON_H
#define	_OH_WEAPON_H
/*******************************************************************************
 **  Name: weapon.h                                                           **
 **  Description:                                                             **
 **                                                                           **
 **  CDDL: Open Source Initiative (OSI) Approved License                      **
 **                                                                           **
 **  Copyright (c) 2009-2010 Barry "Gian" James  <bjames@munixos.net>         **
 **  All rights reserved.                                                     **
 **                                                                           **
 **  The contents of this file are subject to the terms of the CDDL:          **
 **  Common Development and Distribution License (the "License").             **
 **  You may not use this file except in compliance with the License.         **
 **                                                                           **
 **  You can obtain a copy of the license at $PROJECT_ROOT/LICENSE            **
 **  or http://www.opensolaris.org/os/licensing.  This code is Open Source    **
 **  and you are free to use it within the confines of the license, even      **
 **  for your own closed-source commercial projects, as long as you follow    **
 **  the terms set forth in the CDDL.                                         **
 **                                                                           **
 **  When distributing Covered Code, include this CDDL HEADER in each         **
 **  file and include the License file at $PROJECT_ROOT/LICENSE.              **
 **  If applicable, add the following below this CDDL HEADER, with the        **
 **  fields enclosed by brackets "[]" replaced with your own identifying      **
 **  information: Portions Copyright [yyyy] [name of copyright owner]         **
 **                                                                           **
 ******************************************************************************/
// Modified $DateTime$ by $Author$
#define _weapon_h_ID    "$Id$"

#include "component.h"
#include "chassis.h"

struct WpnDmg   // Weapon damage
{
    uint8   roll:3;     // how many dice
    uint8   die:5;      // d12,eg
};

struct WpnMod   // Weapon Modifier
{
    uint8   type:2;
    uint8   recoil:2;       // high recoil reduces accuracy
    uint8   error:2;        // error range. eg if 2 means error on 20-2 or 19-20
    uint8   threat:2;       // same with threat (ie crit)
};

//enum class wpnq
//{ accurate=0x0001, drain=0x0002, composite=0x0004, dependable=0x0008,
//  guided=0x0010, inaccurate=0x0020, overheat=0x0040,
//  stovepipe=0x0080, slowattack=0x0100, slowreload=0x0200, unreliable=0x0400,
//  upgrades=0x0800
//};
enum class wpnFireMode { single, burst, full };

// describes qualities of a wpn that change attributes
//typedef ComponentQuality WpnQuality;   


// flechette, frangible, full-metal jacket, armor-piercing, high explosive incendiary,
// accelerated energy transfer
enum class wpnAmmo : uint8
{ basic, flech, frang, fmj, ap, hei, smoke, flare, cell, blister, pulse,
  phasing, plasma, aet, concussion
};
struct  Ammo
{
    wpnAmmo     type;
    uint8       mod;    // mod id from db
    uint16      weight;
};

enum class wpnCapType : uint8 { mag, belt, drum, cassette, rack, endless };
struct WpnCapacity
{
    uint8   rounds[2];     // how many rounds/pulses/missiles/etc. 0:std,1:curr
    wpnCapType  type;   // magazine, belt, internal, etc
    uint8   reloads;    // how many wpnCapTypes are standard
    Ammo    ammo;       // type of round this capacity holds
    uint8   space;      // space requirement for extra ammo
    WpnCapacity * next; // for carrying multiple types of ammo/magazines/etc
};

enum class wpnArc : uint8 { LOS, arc180, arc360 };

enum class wpnClass
{ ballistic, energy, missile, artillery, explosive, chem, misc };

class Weapon : public Component {
public:
    Weapon();
    Weapon(const char *w);
    Weapon(const Weapon& orig);
    ~Weapon();

    static inline const char * AmmoToStr(wpnAmmo a);

private:
    wpnClass type;
    WpnDmg  dmg;
    WpnMod  mod;
    ChassisLocation mount;  // chassis mount point
    uint8   range[3];       // Short,Medium,Long
    wpnFireMode fireMode;
    uint8   spr;        // shots per round
    WpnCapacity capacity;
    uint8   heat[3];    // 0:heat/shot, 1:curr heat, 2: disippation rate
    wpnArc  coverage;   // what directions does this weapon cover?

    uint16  visual; // an idx into string table for a visual desc of wpn effect
};





/////////////////////[ Energy Weapons
#define WPN_LIGHT_LASER
#define WPN_MED_LASER
#define WPN_HVY_LASER
#define WPN_DISRUPTOR
#define WPN_LIGHT_PHASER
#define WPN_MED_PHASER
#define WPN_HVY_PHASER
#define WPN_GAUSS_RIFLE
#define WPN_PLASMA_

#define WPN_EMP

/////////////////////[ Ballistic Weapons
#define WPN_AUTOCANNON
#define WPN_RAILGUN

/////////////////////[ Missile Weapons
/////////////////////[ Artillery Weapons
#define WPN_MORTAR80                // 80mm

/////////////////////[ Explosive Weapons
#define WPN_GRENADE_LNCHR40         // 40mm
#define WPN_GRENADE_LNCHR120
#define WPN_MINE_AUTOLAY            // mine layer

/////////////////////[ Chemical Weapons

/////////////////////[ Misc Weapons




#endif	/* _OH_WEAPON_H */

